package com.banach.prema.web;

import com.banach.prema.dto.cmd.AlarmAdd;
import com.banach.prema.dto.cmd.AlarmUpd;
import com.banach.prema.dto.query.AlarmPageQuery;
import com.banach.prema.dto.query.MyAlarmPageQuery;
import com.banach.prema.dto.vo.AlarmVO;
import com.banach.prema.service.AlarmService;
import com.ego.framework.annotation.Module;
import com.ego.framework.annotation.RestApi;
import com.ego.framework.dto.Response;
import com.ego.framework.enums.UserType;
import com.ego.framework.model.CustomizePage;
import com.ego.ucenter.security.annotation.RequireLogin;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ajun
 *
 */
@RestController
@RequestMapping(value = "/alarm")
@Module("风险预警")
public class AlarmController{

	@Resource
	private AlarmService alarmService;

	/**
	 * 查询风险预警列表
	 * @return
	 */
	@GetMapping(value="/page")
	@RestApi(name = "查询风险预警列表",idx = 0)
	public Response<CustomizePage<AlarmVO>> selectPage(AlarmPageQuery pageQuery){
		return alarmService.selectPage(pageQuery);
	}

	@GetMapping(value="/mine/page")
	@RestApi(name = "查询我的风险预警列表",idx = 2)
	public Response<CustomizePage<AlarmVO>> selectMyPage(MyAlarmPageQuery pageQuery){
		return alarmService.selectMyPage(pageQuery);
	}

	/**
	 * 发布风险预警
	 * @return
	 */
	@PostMapping(value="/publish")
	@RestApi(name = "发布风险预警",idx = 3)
	public Response publish(@RequestBody AlarmAdd alarmAdd) {
		return alarmService.publish(alarmAdd);
	}


	@PutMapping(value="/republish")
	@RestApi(name = "重发布风险预警",idx = 4)
	public Response republish(@RequestBody AlarmUpd alarmUpd) {
		return alarmService.republish(alarmUpd);
	}

	/**
	 * 删除风险预警
	 * @return
	 */
	@DeleteMapping(value="/delete")
	@RestApi(name = "删除风险预警",idx = 5)
	public Response delete(@RequestBody List<Long> ids) {
		return alarmService.delete(ids);
	}
}
